/*
	Copyright (c) 2007, ANYwebcam.com Pty Ltd. All rights reserved.

	The software in this package is published under the terms of the BSD style 
	license, a copy of which has been included with this distribution in the 
	license.txt file.
*/
package com.anywebcam.di.component
{
	import com.anywebcam.di.*;
	import com.anywebcam.di.component.*;
	import com.anywebcam.di.testsupport.*;

	import flexunit.framework.TestCase;
	import flexunit.framework.TestSuite;

	public class SetterInjectionComponentTest extends TestCase
	{
		public static function suite():TestSuite
		{
			var ts:TestSuite = new TestSuite();

			var tests:Array = 
			[
				'shouldComplainIfInstanceDoesNotProvideASetterForTheSpecifiedParameter',
				
				// ['propertyOne', 'propertyTwo']
				'shouldResolveSimpleStringParameterToSetterAndRetrieveTypeInstanceFromContainer',

				// key:String, value:String
				// eg: [{'propertyOne': 'string-key'}]
				'shouldResolveParameterWithStringKeyAndStringValueToTypeInstanceFromContainer',
				
				// key:String, value:Function
				// eg: [{'propertyTwo': function( container:DIContainer, component:DIComponent, parameter:* ):Object { return { hello : 'world' }; } }]
				'shouldResolveParameterWithStringKeyAndFunctionValueToFunctionReturnValue',
				
				// key:String, value:Class
				// eg: [{'propertyThree': ClassWithSetters}]
				'shouldResolveParameterWithStringKeyAndClassValueToTypeInstanceFromContainer',
			];

			tests.forEach( function( methodName:String, index:int, array:Array ):void
			{
				ts.addTest( new SetterInjectionComponentTest( methodName ) );
			});

			return ts;
		}

		private var container:DIContainer;

		public function SetterInjectionComponentTest( method:String )
		{
			super( method );
		}
		
		override public function setUp():void
		{
			container = new DefaultDIContainer();
		}

		public function shouldComplainIfInstanceDoesNotProvideASetterForTheSpecifiedParameter():void
		{
			var component:SetterInjectionComponent = new SetterInjectionComponent( ClassWithoutSetters, ClassWithoutSetters, ['nonExistantSetter'] );		
			try
			{
				component.getInstance( container );
				fail( 'Expecting SetterInjectionComponent to complain when setting a non-existant setter' );
			}
			catch( e:UnsettableSetterError )
			{
			}
		}
		
		public function shouldResolveSimpleStringParameterToSetterAndRetrieveTypeInstanceFromContainer():void
		{
			fail( 'test not yet implemented' );
			var component:SetterInjectionComponent = new SetterInjectionComponent( ClassWithSetters, ClassWithSetters, [''] );
		}
		
		public function shouldResolveParameterWithStringKeyAndStringValueToTypeInstanceFromContainer():void
		{
			fail( 'test not yet implemented' );
			var component:SetterInjectionComponent = new SetterInjectionComponent();
		}
		
		public function shouldResolveParameterWithStringKeyAndFunctionValueToFunctionReturnValue():void
		{
			fail( 'test not yet implemented' );
			var component:SetterInjectionComponent = new SetterInjectionComponent();
		}
		
		public function shouldResolveParameterWithStringKeyAndClassValueToTypeInstanceFromContainer():void
		{
			fail( 'test not yet implemented' );
			var component:SetterInjectionComponent = new SetterInjectionComponent();
		}
	}
}